﻿using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        // 生成100个随机数
        var rnd = new Random();
        var numbers = Enumerable.Range(0, 100)
            .Select(_ => rnd.Next(0, 1001))
            .ToList(); 

        // LINQ处理流程（单语句链式操作）
        var processed = numbers
            .OrderByDescending(n => n) 
            .Select((n, index) => new { Number = n, Group = index / 10 })
            .GroupBy(x => x.Group)  
            .ToList();

        // 输出格式化 
        Console.WriteLine("【降序排列结果】（每行10个）");
        foreach (var group in processed)
        {
            Console.WriteLine(string.Join(", ", group.Select(x => x.Number)));
        }

        // 统计计算
        var sum = numbers.Sum();
        var avg = numbers.Average();
        Console.WriteLine($"\n总和：{sum:N0}");
        Console.WriteLine($"平均数：{avg:##.00}");


        Console.ReadLine();
    }
}